package Handler;

import javax.swing.JComponent;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author Araya
 */
public class ExportTransferHandler extends StringTransferHandler {

    private int[] rows = null;
    private int addIndex = -1; //Location where items were added
    private int addCount = 0; //Number of items added.

    public ExportTransferHandler() {
        rows = null;
        addIndex = -1;
        addCount = 0;
    }

    protected String exportString(JComponent c) {
        JTable table = (JTable) c;
        rows = table.getSelectedRows();
        int colCount = table.getColumnCount();

        StringBuffer buff = new StringBuffer();
        for (int i = 0; i < rows.length; i++) {
            Object val = table.getValueAt(rows[i], 0) + "-" + table.getValueAt(rows[i], 1);
            buff.append(val == null ? "" : val.toString());
            if (i != rows.length - 1) {
                buff.append("\n");
            }
        }
        return buff.toString();
    }

    protected void importString(JComponent c, String str) {
        //No implementado
    }

    protected void cleanup(JComponent c, boolean remove) {
        //No implementado
    }

}
